import Router from 'koa-router';
import userController from '@/controllers/user.controller';
import authMiddleware from '@/middlewares/auth.middleware';

const router = new Router({prefix: '/api/users'});

// 公开路由
router.post('/login', userController.login);

// 需要认证的路由
router.post('/logout', authMiddleware, userController.logout);

// 获取用户个人信息
router.get('/profile', authMiddleware, userController.getProfile);

// 获取用户所有权限
router.get('/permissions', authMiddleware, userController.getUserPermissions);

// 创建用户
router.post('/create', authMiddleware, userController.createUser);

// 获取用户列表
router.post('/list', authMiddleware, userController.getUserList);

// 删除用户
router.post('/delete/:id', authMiddleware, userController.deleteUser);

// 修改用户信息
router.post('/update/:id', authMiddleware, userController.updateUser);

export default router;
